package file;

import java.io.File;
import java.io.FileFilter;

/**
 * 获取当前目录中所有名字含有o的子项
 */
public class Test2 {
    public static void main(String[] args) {


    FileFilter filter = new FileFilter() {
        @Override
        public boolean accept(File file) {
            String fileName = file.getName();
            return fileName.contains("a");
        }
    };
    File dir = new File(".");
    if(dir.isDirectory()){
        File[] subs = dir.listFiles(filter);

        System.out.println("共包含"+subs.length+"个子项");
        for (int i = 0;i< subs.length;i++){
            System.out.println(subs[i].getName());
        }
    }
    }
}
